<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客管理登录</title>
    <link rel="stylesheet" type="text/css" href="../../static/css/semantic.min.css" th:href="@{/css/semantic.min.css}">
    <link rel="stylesheet" type="text/css" href="../../static/css/div.css" th:href="@{/css/me.css}">
    <link rel="stylesheet" type="text/css" href="../../static/lib/editormd/css/editormd.min.css"
          th:href="@{/lib/editormd/css/editormd.min.css}">
</head>
<body>

<br>
<br>
<br>
<div class="m-container-small m-padded-tb-massive" style="max-width: 30em !important;">
    <div class="ur container">
        <div class="ui middle aligned center aligned grid">
            <div class="column">
                <h2 class="ui teal image header">
                    <div class="content">
                        登录
                    </div>
                </h2>
                <form class="ui large form" method="post" action="#" th:action="@{/admin/login}">
                    <div class="ui segment">
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="user icon"></i>
                                <input type="text" name="username" placeholder="用户名">
                            </div>
                        </div>
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="lock icon"></i>
                                <input type="password" name="password" placeholder="密码">
                            </div>
                        </div>
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="question circle icon"></i>
                                <input type="text" name="captcha" placeholder="验证码">
                                <img id="captcha" src="@{/admin/captcha.jpg}" th:src="@{/admin/captcha.jpg}"/>
                            </div>
                        </div>
                        <button class="ui fluid large teal submit button">登 录</button>
                    </div>
                    <div class="ui message">
                        New to us? <a  href="#" th:href="@{/register}" target="_self">Sign Up</a>
                    </div>

                    <div class="ui error mini message"></div>
                    <div class="ui mini negative message" th:unless="${#strings.isEmpty(message)}" th:text="${message}">
                        用户名和密码错误
                    </div>

                </form>

            </div>
        </div>
    </div>
</div>

<!--semantic同bootstrap,基于jquery开发的-->
<script src="../../static/js/jquery-3.5.1.min.js" th:src="@{/js/jquery-3.5.1.min.js}"></script>
<!--引入semantic的js-->
<script src="../../static/js/semantic.min.js" th:src="@{/js/semantic.min.js}"></script>

<script>
    //这段代码可以实现在360极速浏览器（8.7.0.306）和谷歌浏览器（57.0.2987.133）上点击验证码位置刷新，
    //但是在火狐浏览器（53.0.0.6312）和微软自带浏览器不能实现点击验证码位置的刷新功能。
    //为了在所有浏览器上都能实现点击验证码的刷新功能，我们可以在上述代码中添加随机参数，对浏览器进行欺骗。
    $('#captcha').click(function () {
             this.src = "/admin/captcha.jpg?"+Math.random();
    });
    $('.ui.form').form({
        fields: {
            username: {
                identifier: 'username',
                rules: [{
                    type: 'empty',
                    prompt: '请输入用户名'
                }]
            },
            password: {
                identifier: 'password',
                rules: [{
                    type: 'empty',
                    prompt: '请输入密码'
                }]
            }
        }
    });
</script>

</body>
</html>